<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/webui/style/admin.css" media="all">
    <link rel="stylesheet" href="/webui/style/login.css" media="all">
</head>
<body>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>修改密码</h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="passwordOld" id="LAY-user-login-passwordOld" lay-verify="required" placeholder="原密码" class="layui-input">
            </div>

            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="passwordNew" id="LAY-user-login-passwordNew" lay-verify="required" placeholder="新密码" class="layui-input">
            </div>

            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="passwordNewC" id="LAY-user-login-passwordNewC" lay-verify="required" placeholder="再输一遍" class="layui-input">
            </div>

            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login" id="login">修 改</button>
            </div>

        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">
        <p>© 2018 <a href="#" target="_blank">cosjs.com</a></p>
    </div>

</div>
<script src="/layui/layui.js"></script>
<script>
    layui.config({
        base: '/webui/'  // 模块目录
    }).extend({
        "cosjs":"{/}/layui/?name=cosjs"
    }).use(['form','cosjs'], function () {
        var form = layui.form,$ = layui.jquery,cosjs=layui.cosjs;
        form.on('submit(login)', function(data){
            if(data.field.passwordNew!==data.field.passwordNewC){
                cosjs.alert("新密码两次输入不一致");
            }else{
                //let index = layer.load(2);
                let  url ='/changePass/submit';
                cosjs.post(url,data.field).then(ret=>{
                    window.location.href ='/';
                    cosjs.alert("修改成功，请重新登录");
                }).catch(err=>{
                    cosjs.alert(err);
                    //layer.close(index);
                })      
            }
            //console.log(data);
            return false;
        })
        if (window!=top){
            top.location.href =window.location.href;
        }
    });
</script>
</body>
</html>